package org.example.campus_sys_backend.controller;

import org.example.campus_sys_backend.model.StudentInfo;
import org.example.campus_sys_backend.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    public StudentService studentService;
    @RequestMapping("/add")
    public Boolean addStudent(StudentInfo studentInfo){
        if(studentInfo != null){
            studentService.insertStudent(studentInfo);
            return true;
        }
        return false;
    }
    @RequestMapping("/update")
    public Boolean updStudent(Integer id){
        if (id > 0){
            studentService.updateStudent(id);
            return true;
        }
        return false;
    }
    @RequestMapping("/alt")
    public Boolean altStudent(Integer id,Integer classId){
        if (id > 0){
            studentService.allotStudent(id,classId);
            return true;
        }
        return false;
    }
}
